<template>
  <a-card :bordered="false" :style="{ marginTop: '12px',height:'450px' }">
    <span slot="title"> <a-icon type="tags" style="color:#3393FC;margin-right: 5px" theme="filled"/>流程提醒</span>
    <a slot="extra" @click="loadMore('/isps/userAnnouncement')">更多</a>
    <template v-if="processNotice.length>0">
      <a-list itemLayout="horizontal" :dataSource="processNotice">
        <a-list-item @click="showAnnouncement(item)" slot="renderItem" :key="index" slot-scope="item, index">
          <a-list-item-meta>
            <a slot="title" href="#" :style="{color:item.readFlag=='0'?'':'#d2d2d2'}">{{item.titile}}</a>
          </a-list-item-meta>
          <div>{{item.sendTime}}</div>
        </a-list-item>
      </a-list>
    </template>
    <template v-else>
      <a-empty />
    </template>
    <dynamic-notice ref="showDynamNotice" :path="openPath" :formData="formDataNotice"/>
    <show-announcement ref="ShowAnnouncement" @ok="modalFormOk"></show-announcement>
  </a-card>
</template>

<script>
  import DynamicNotice from '@/components/tools/DynamicNotice'
  import ShowAnnouncement from '@/components/tools/ShowAnnouncement'
  import { getUserNoticeInfo } from '@/api/api'
  import { putAction } from '@/api/manage'

  export default {
    name: 'EoaCmsProcessNotice',
    components: {
      ShowAnnouncement,
      DynamicNotice,
    },
    data () {
      return {
        processNotice: [],
        formDataNotice: {},
        openPath: '',
      }
    },
    created() {
      this.getData();
    },
    methods: {
      modalFormOk(){
        console.log("===modalFormOk===");
        this.getData();
      },
      showAnnouncement(record){
        putAction('/sys/sysAnnouncementSend/editByAnntIdAndUserId',{anntId:record.anntId}).then((res)=> {
          if (res.success) {
            this.getData();
          }
        });
        if(record.openType==='component'){
          this.openPath = record.openPage;
          this.formDataNotice = {id:record.busId};
          this.$refs.showDynamNotice.detail(record.openPage);
        }else{
          this.$refs.ShowAnnouncement.detail(record);
        }
      },
      loadMore(path){
        let query={}
        this.$router.push({ path: path,query:query})
      },
      getData(){
        getUserNoticeInfo({pageNo:1,pageSize:5,busType:'bpm'}).then((res)=>{
          console.log("getUserNoticeInfo===busType",res);
          if(res.success){
            this.processNotice=res.result.records;
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>